/*
 * File: fault_diagnosis.c
 *
 * Code generated for Simulink model 'fault_diagnosis'.
 *
 * Model version                  : 1.1
 * Simulink Coder version         : 9.5 (R2021a) 14-Nov-2020
 * C/C++ source code generated on : Thu Mar 14 20:23:48 2024
 *
 * Target selection: ert.tlc
 * Embedded hardware selection: ARM Compatible->ARM Cortex-M
 * Code generation objective: MISRA C:2012 guidelines
 * Validation result: Not run
 */

#include "fault_diagnosis.h"
#include "fault_diagnosis_private.h"

/* Block signals (default storage) */
B_fault_diagnosis_T fault_diagnosis_B;

/* Block states (default storage) */
DW_fault_diagnosis_T fault_diagnosis_DW;

/* Real-time model */
static RT_MODEL_fault_diagnosis_T fault_diagnosis_M_;
RT_MODEL_fault_diagnosis_T *const fault_diagnosis_M = &fault_diagnosis_M_;

/* Exported data definition */

/* Definition for custom storage class: ExportToFile */
uint8_T KaFDG_CellDiffTempLevC[3] =
{
    60U, 62U, 65U
} ;                                    /* Referenced by: '<S7>/Constant' */

/* 单体温差等级电压(Factor:1.000000,Offset:-50) */
uint8_T KaFDG_CellDiffTempLevRecoverC[3] =
{
    58U, 60U, 62U
} ;                                    /* Referenced by: '<S8>/Constant8' */

/* 单体温差等级恢复电压(Factor:1.000000,Offset:-50) */
uint16_T KaFDG_CellDiffTempLevRecvryTimerMs[3] =
{
    10000U, 10000U, 10000U
} ;                                    /* Referenced by:
                                        * '<S8>/Constant2'
                                        * '<S8>/Constant4'
                                        * '<S8>/Constant7'
                                        */

/* 单体温差恢复滤波时间 */
uint16_T KaFDG_CellDiffTempTimerMs[3] =
{
    10000U, 5000U, 3000U
} ;                                    /* Referenced by:
                                        * '<S7>/Constant10'
                                        * '<S7>/Constant4'
                                        * '<S7>/Constant7'
                                        */

/* 单体温差滤波时间 */
uint16_T KaFDG_CellDiffVoltLevMv[3] =
{
    200U, 300U, 500U
} ;                                    /* Referenced by: '<S18>/Constant' */

/* 单体电压差等级电压 */
uint16_T KaFDG_CellDiffVoltLevRecoverMv[3] =
{
    100U, 200U, 400U
} ;                                    /* Referenced by: '<S19>/Constant8' */

/* 单体电压差等级恢复电压 */
uint16_T KaFDG_CellDiffVoltLevRecvryTimerMs[3] =
{
    10000U, 10000U, 10000U
} ;                                    /* Referenced by:
                                        * '<S19>/Constant2'
                                        * '<S19>/Constant4'
                                        * '<S19>/Constant7'
                                        */

/* 单体电压差恢复滤波时间 */
uint16_T KaFDG_CellDiffVoltTimerMs[3] =
{
    10000U, 5000U, 3000U
} ;                                    /* Referenced by:
                                        * '<S18>/Constant10'
                                        * '<S18>/Constant4'
                                        * '<S18>/Constant7'
                                        */

/* 单体电压差滤波时间 */
uint8_T KaFDG_CellOvrTempLevC[3] =
{
    98U, 102U, 105U
} ;                                    /* Referenced by: '<S20>/Constant' */

/* 单体过温等级电压(Factor:1.000000,Offset:-50) */
uint8_T KaFDG_CellOvrTempLevRecoverC[3] =
{
    96U, 100U, 101U
} ;                                    /* Referenced by: '<S21>/Constant8' */

/* 单体过温等级恢复电压(Factor:1.000000,Offset:-50) */
uint16_T KaFDG_CellOvrTempLevRecvryTimerMs[3] =
{
    10000U, 10000U, 10000U
} ;                                    /* Referenced by:
                                        * '<S21>/Constant2'
                                        * '<S21>/Constant4'
                                        * '<S21>/Constant7'
                                        */

/* 单体过压恢复滤波时间 */
uint16_T KaFDG_CellOvrTempTimerMs[3] =
{
    10000U, 5000U, 3000U
} ;                                    /* Referenced by:
                                        * '<S20>/Constant10'
                                        * '<S20>/Constant4'
                                        * '<S20>/Constant7'
                                        */

/* 单体过温滤波时间 */
uint16_T KaFDG_CellOvrVoltLevMv[3] =
{
    3700U, 3850U, 4000U
} ;                                    /* Referenced by: '<S5>/Constant' */

/* 单体电压过压等级电压 */
uint16_T KaFDG_CellOvrVoltLevRecoverMv[3] =
{
    3690U, 3840U, 3990U
} ;                                    /* Referenced by: '<S6>/Constant8' */

/* 单体电压过压等级恢复电压 */
uint16_T KaFDG_CellOvrVoltLevRecvryTimerMs[3] =
{
    10000U, 10000U, 10000U
} ;                                    /* Referenced by:
                                        * '<S6>/Constant2'
                                        * '<S6>/Constant4'
                                        * '<S6>/Constant7'
                                        */

/* 单体电压过压恢复滤波时间 */
uint16_T KaFDG_CellOvrVoltTimerMs[3] =
{
    10000U, 5000U, 3000U
} ;                                    /* Referenced by:
                                        * '<S5>/Constant10'
                                        * '<S5>/Constant4'
                                        * '<S5>/Constant7'
                                        */

/* 单体电压过压滤波时间 */
uint8_T KaFDG_CellUnderTempLevC[3] =
{
    30U, 25U, 20U
} ;                                    /* Referenced by: '<S22>/Constant' */

/* 单体欠温等级电压(Factor:1.000000,Offset:-50) */
uint8_T KaFDG_CellUnderTempLevRecoverC[3] =
{
    32U, 28U, 33U
} ;                                    /* Referenced by: '<S23>/Constant8' */

/* 单体欠温等级恢复电压(Factor:1.000000,Offset:-50) */
uint16_T KaFDG_CellUnderTempLevRecvryTimerMs[3] =
{
    10000U, 10000U, 10000U
} ;                                    /* Referenced by:
                                        * '<S23>/Constant2'
                                        * '<S23>/Constant4'
                                        * '<S23>/Constant7'
                                        */

/* 单体欠温恢复滤波时间 */
uint16_T KaFDG_CellUnderTempTimerMs[3] =
{
    10000U, 5000U, 3000U
} ;                                    /* Referenced by:
                                        * '<S22>/Constant10'
                                        * '<S22>/Constant4'
                                        * '<S22>/Constant7'
                                        */

/* 单体欠温滤波时间 */
uint16_T KaFDG_CellUnderVoltLevMv[3] =
{
    2800U, 2700U, 2600U
} ;                                    /* Referenced by: '<S16>/Constant' */

/* 单体电压欠压等级电压 */
uint16_T KaFDG_CellUnderVoltLevRecoverMv[3] =
{
    3010U, 2910U, 2810U
} ;                                    /* Referenced by: '<S17>/Constant8' */

/* 单体电压欠压等级恢复电压 */
uint16_T KaFDG_CellUnderVoltLevRecvryTimerMs[3] =
{
    10000U, 10000U, 10000U
} ;                                    /* Referenced by:
                                        * '<S17>/Constant2'
                                        * '<S17>/Constant4'
                                        * '<S17>/Constant7'
                                        */

/* 单体电压欠压恢复滤波时间 */
uint16_T KaFDG_CellUnderVoltTimerMs[3] =
{
    10000U, 5000U, 3000U
} ;                                    /* Referenced by:
                                        * '<S16>/Constant10'
                                        * '<S16>/Constant4'
                                        * '<S16>/Constant7'
                                        */

/* 单体电压欠压滤波时间 */
uint16_T KaFDG_DevDaisyCommTimeoutMs = 5000U;/* Referenced by: '<S15>/Constant' */

/* 菊花链通信超时时间 */

/* Definition for custom storage class: ExportToFile */
boolean_T SbFDG_CellDiffTempLev1Flg;   /* '<S4>/Subsystem10' */

/* 单体温差1级故障 */
boolean_T SbFDG_CellDiffTempLev2Flg;   /* '<S4>/Subsystem10' */

/* 单体温差2级故障 */
boolean_T SbFDG_CellDiffTempLev3Flg;   /* '<S4>/Subsystem10' */

/* 单体温差3级故障 */
boolean_T SbFDG_CellDiffVoltLev1Flg;   /* '<S4>/Subsystem4' */

/* 单体压差1级故障 */
boolean_T SbFDG_CellDiffVoltLev2Flg;   /* '<S4>/Subsystem4' */

/* 单体压差2级故障 */
boolean_T SbFDG_CellDiffVoltLev3Flg;   /* '<S4>/Subsystem4' */

/* 单体压差3级故障 */
boolean_T SbFDG_CellOvrTempLev1Flg;    /* '<S4>/Subsystem6' */

/* 单体过温1级故障 */
boolean_T SbFDG_CellOvrTempLev2Flg;    /* '<S4>/Subsystem6' */

/* 单体过温2级故障 */
boolean_T SbFDG_CellOvrTempLev3Flg;    /* '<S4>/Subsystem6' */

/* 单体过温3级故障 */
boolean_T SbFDG_CellOvrVoltLev1Flg;    /* '<S4>/Subsystem' */

/* 单体过压1级故障 */
boolean_T SbFDG_CellOvrVoltLev2Flg;    /* '<S4>/Subsystem' */

/* 单体过压2级故障 */
boolean_T SbFDG_CellOvrVoltLev3Flg;    /* '<S4>/Subsystem' */

/* 单体过压3级故障 */
boolean_T SbFDG_CellUnderTempLev1Flg;  /* '<S4>/Subsystem8' */

/* 单体欠温1级故障 */
boolean_T SbFDG_CellUnderTempLev2Flg;  /* '<S4>/Subsystem8' */

/* 单体欠温2级故障 */
boolean_T SbFDG_CellUnderTempLev3Flg;  /* '<S4>/Subsystem8' */

/* 单体欠温3级故障 */
boolean_T SbFDG_CellUnderVoltLev1Flg;  /* '<S4>/Subsystem2' */

/* 单体欠压1级故障 */
boolean_T SbFDG_CellUnderVoltLev2Flg;  /* '<S4>/Subsystem2' */

/* 单体欠压2级故障 */
boolean_T SbFDG_CellUnderVoltLev3Flg;  /* '<S4>/Subsystem2' */

/* 单体欠压3级故障 */
boolean_T SbFDG_DevDaisyCommFlt;       /* '<S15>/fault_diagnosis_IncreaseTimer' */

/* 菊花链通信故障 */
uint8_T ScFDG_PackFaltLevel;           /* '<S4>/Max' */

/* Pack故障等级 */

/*
 * Output and update for atomic system:
 *    '<S5>/fault_diagnosis_IncreaseTimer'
 *    '<S6>/fault_diagnosis_IncreaseTimer'
 *    '<S7>/fault_diagnosis_IncreaseTimer'
 *    '<S8>/fault_diagnosis_IncreaseTimer'
 *    '<S16>/fault_diagnosis_IncreaseTimer'
 *    '<S17>/fault_diagnosis_IncreaseTimer'
 *    '<S18>/fault_diagnosis_IncreaseTimer'
 *    '<S19>/fault_diagnosis_IncreaseTimer'
 *    '<S20>/fault_diagnosis_IncreaseTimer'
 *    '<S21>/fault_diagnosis_IncreaseTimer'
 *    ...
 */
void fault_diagnosis_IncreaseTimer(boolean_T Reset, boolean_T Enable, uint16_T UpperLim, real_T
                   Step, B_IncreaseTimer_fault_diagnos_T *localB,
                   DW_IncreaseTimer_fault_diagno_T *localDW)
{
    real_T Switch4;
    uint16_T Switch3;
    if (Reset)
    {
        Switch3 = 0U;
    }
    else
    {
        if (Enable)
        {
            Switch4 = Step + (real_T)localDW->U_DSTATE;
        }
        else
        {
            Switch4 = localDW->U_DSTATE;
        }

        if (Switch4 < 65536.0)
        {
            if (Switch4 >= 0.0)
            {
                Switch3 = (uint16_T)Switch4;
            }
            else
            {
                Switch3 = 0U;
            }
        }
        else
        {
            Switch3 = MAX_uint16_T;
        }
    }

    if (Switch3 >= UpperLim)
    {
        Switch3 = UpperLim;
    }

    localB->RelationalOperator_k = (Switch3 == UpperLim);
    localDW->U_DSTATE = Switch3;
}

/*
 * Output and update for atomic system:
 *    '<S5>/fault_diagnosis_IncreaseTimer1'
 *    '<S6>/fault_diagnosis_IncreaseTimer1'
 *    '<S7>/fault_diagnosis_IncreaseTimer1'
 *    '<S8>/fault_diagnosis_IncreaseTimer1'
 *    '<S16>/fault_diagnosis_IncreaseTimer1'
 *    '<S17>/fault_diagnosis_IncreaseTimer1'
 *    '<S18>/fault_diagnosis_IncreaseTimer1'
 *    '<S19>/fault_diagnosis_IncreaseTimer1'
 *    '<S20>/fault_diagnosis_IncreaseTimer1'
 *    '<S21>/fault_diagnosis_IncreaseTimer1'
 *    ...
 */
void fault_diagnosis_IncreaseTimer1(boolean_T Reset, boolean_T Enable, uint16_T UpperLim, real_T
                    Step, B_IncreaseTimer1_fault_diagno_T *localB,
                    DW_IncreaseTimer1_fault_diagn_T *localDW)
{
    real_T Switch4;
    uint16_T Switch3;
    if (Reset)
    {
        Switch3 = 0U;
    }
    else
    {
        if (Enable)
        {
            Switch4 = Step + (real_T)localDW->U_DSTATE;
        }
        else
        {
            Switch4 = localDW->U_DSTATE;
        }

        if (Switch4 < 65536.0)
        {
            if (Switch4 >= 0.0)
            {
                Switch3 = (uint16_T)Switch4;
            }
            else
            {
                Switch3 = 0U;
            }
        }
        else
        {
            Switch3 = MAX_uint16_T;
        }
    }

    if (Switch3 >= UpperLim)
    {
        Switch3 = UpperLim;
    }

    localB->RelationalOperator_n4 = (Switch3 == UpperLim);
    localDW->U_DSTATE = Switch3;
}

/*
 * Output and update for atomic system:
 *    '<S5>/fault_diagnosis_IncreaseTimer2'
 *    '<S6>/fault_diagnosis_IncreaseTimer2'
 *    '<S7>/fault_diagnosis_IncreaseTimer2'
 *    '<S8>/fault_diagnosis_IncreaseTimer2'
 *    '<S16>/fault_diagnosis_IncreaseTimer2'
 *    '<S17>/fault_diagnosis_IncreaseTimer2'
 *    '<S18>/fault_diagnosis_IncreaseTimer2'
 *    '<S19>/fault_diagnosis_IncreaseTimer2'
 *    '<S20>/fault_diagnosis_IncreaseTimer2'
 *    '<S21>/fault_diagnosis_IncreaseTimer2'
 *    ...
 */
void fault_diagnosis_IncreaseTimer2(boolean_T Reset, boolean_T Enable, uint16_T UpperLim, real_T
                    Step, B_IncreaseTimer2_fault_diagno_T *localB,
                    DW_IncreaseTimer2_fault_diagn_T *localDW)
{
    real_T Switch4;
    uint16_T Switch3;
    if (Reset)
    {
        Switch3 = 0U;
    }
    else
    {
        if (Enable)
        {
            Switch4 = Step + (real_T)localDW->U_DSTATE;
        }
        else
        {
            Switch4 = localDW->U_DSTATE;
        }

        if (Switch4 < 65536.0)
        {
            if (Switch4 >= 0.0)
            {
                Switch3 = (uint16_T)Switch4;
            }
            else
            {
                Switch3 = 0U;
            }
        }
        else
        {
            Switch3 = MAX_uint16_T;
        }
    }

    if (Switch3 >= UpperLim)
    {
        Switch3 = UpperLim;
    }

    localB->RelationalOperator_a = (Switch3 == UpperLim);
    localDW->U_DSTATE = Switch3;
}

/* Output and update for atomic system: '<S15>/fault_diagnosis_IncreaseTimer' */
void fault_diagnosis_IncreaseTimer_f(boolean_T Reset, boolean_T Enable, uint16_T UpperLim,
                     real_T Step, B_IncreaseTimer_fault_diagn_i_T *localB,
                     DW_IncreaseTimer_fault_diag_d_T *localDW)
{
    real_T Switch4;
    uint16_T Switch3;
    if (Reset)
    {
        Switch3 = 0U;
    }
    else
    {
        if (Enable)
        {
            Switch4 = Step + (real_T)localDW->U_DSTATE;
        }
        else
        {
            Switch4 = localDW->U_DSTATE;
        }

        if (Switch4 < 65536.0)
        {
            if (Switch4 >= 0.0)
            {
                Switch3 = (uint16_T)Switch4;
            }
            else
            {
                Switch3 = 0U;
            }
        }
        else
        {
            Switch3 = MAX_uint16_T;
        }
    }

    if (Switch3 >= UpperLim)
    {
        Switch3 = UpperLim;
    }

    localB->RelationalOperator_p = (Switch3 == UpperLim);
    localDW->U_DSTATE = Switch3;
}

/* Model step function */
void fault_diagnosis_step(void)
{
    uint8_T u1;
    uint8_T u1_0;
    uint8_T u1_1;
    uint8_T u1_2;
    uint8_T u1_3;
    uint8_T u1_4;
    uint8_T u1_5;
    uint8_T u1_6;
    uint8_T u1_7;
    uint8_T u1_8;
    uint8_T u1_9;
    uint8_T u1_a;
    boolean_T U;
    boolean_T U1;
    boolean_T U1_a;
    boolean_T U1_c;
    boolean_T U1_gg;
    boolean_T U1_j;
    boolean_T U1_n;
    boolean_T U2;
    boolean_T U2_b;
    boolean_T U2_bw;
    boolean_T U2_d;
    boolean_T U2_e;
    boolean_T U2_f;
    boolean_T U_c;
    boolean_T U_h;
    boolean_T U_mq;
    boolean_T U_p;
    U = fault_diagnosis_DW.U_DSTATE;
    U1 = fault_diagnosis_DW.U1_DSTATE;
    U2 = fault_diagnosis_DW.U2_DSTATE;
    if (SbBSW_AfeDataGetAllFlg)
    {
        fault_diagnosis_IncreaseTimer1(U1, ScBSW_PackMinCellTempC <= KaFDG_CellUnderTempLevC[1],
                       KaFDG_CellUnderTempTimerMs[1], 100.0,
                       &fault_diagnosis_B.IncreaseTimer1_k,
                       &fault_diagnosis_DW.IncreaseTimer1_k);
        fault_diagnosis_IncreaseTimer(U, ScBSW_PackMinCellTempC <= KaFDG_CellUnderTempLevC[0],
                      KaFDG_CellUnderTempTimerMs[0], 100.0,
                      &fault_diagnosis_B.IncreaseTimer_i,
                      &fault_diagnosis_DW.IncreaseTimer_i);
        fault_diagnosis_IncreaseTimer2(U2, ScBSW_PackMinCellTempC <= KaFDG_CellUnderTempLevC[2],
                       KaFDG_CellUnderTempTimerMs[2], 100.0,
                       &fault_diagnosis_B.IncreaseTimer2_ln,
                       &fault_diagnosis_DW.IncreaseTimer2_ln);
    }

    SbFDG_CellUnderTempLev1Flg =
        fault_diagnosis_B.IncreaseTimer_i.RelationalOperator_k;
    fault_diagnosis_IncreaseTimer(U, SbFDG_CellUnderTempLev1Flg && (ScBSW_PackMinCellTempC >
                   KaFDG_CellUnderTempLevRecoverC[0]),
                  KaFDG_CellUnderTempLevRecvryTimerMs[0], 100.0,
                  &fault_diagnosis_B.IncreaseTimer_fy,
                  &fault_diagnosis_DW.IncreaseTimer_fy);
    SbFDG_CellUnderTempLev2Flg =
        fault_diagnosis_B.IncreaseTimer1_k.RelationalOperator_n4;
    SbFDG_CellUnderTempLev3Flg =
        fault_diagnosis_B.IncreaseTimer2_ln.RelationalOperator_a;
    U = fault_diagnosis_DW.U_DSTATE_i;
    U1_gg = fault_diagnosis_DW.U1_DSTATE_l;
    U2_d = fault_diagnosis_DW.U2_DSTATE_n;
    if (SbBSW_AfeDataGetAllFlg)
    {
        fault_diagnosis_IncreaseTimer1(U1_gg, ScBSW_PackMaxCellVoltMv >= KaFDG_CellOvrVoltLevMv
                       [1], KaFDG_CellOvrVoltTimerMs[1], 100.0,
                       &fault_diagnosis_B.IncreaseTimer1_c,
                       &fault_diagnosis_DW.IncreaseTimer1_c);
        fault_diagnosis_IncreaseTimer(U, ScBSW_PackMaxCellVoltMv >= KaFDG_CellOvrVoltLevMv[0],
                      KaFDG_CellOvrVoltTimerMs[0], 100.0,
                      &fault_diagnosis_B.IncreaseTimer_m,
                      &fault_diagnosis_DW.IncreaseTimer_m);
        fault_diagnosis_IncreaseTimer2(U2_d, ScBSW_PackMaxCellVoltMv >= KaFDG_CellOvrVoltLevMv[2],
                       KaFDG_CellOvrVoltTimerMs[2], 100.0,
                       &fault_diagnosis_B.IncreaseTimer2_bi,
                       &fault_diagnosis_DW.IncreaseTimer2_bi);
    }

    SbFDG_CellOvrVoltLev1Flg =
        fault_diagnosis_B.IncreaseTimer_m.RelationalOperator_k;
    SbFDG_CellOvrVoltLev2Flg =
        fault_diagnosis_B.IncreaseTimer1_c.RelationalOperator_n4;
    SbFDG_CellOvrVoltLev3Flg =
        fault_diagnosis_B.IncreaseTimer2_bi.RelationalOperator_a;
    U_c = fault_diagnosis_DW.U_DSTATE_k;
    U1_c = fault_diagnosis_DW.U1_DSTATE_g;
    U2_bw = fault_diagnosis_DW.U2_DSTATE_d;
    if (SbBSW_AfeDataGetAllFlg)
    {
        fault_diagnosis_IncreaseTimer1(U1_c, ScBSW_PackMinCellVoltMv <=
                       KaFDG_CellUnderVoltLevMv[1], KaFDG_CellUnderVoltTimerMs[1],
                       100.0, &fault_diagnosis_B.IncreaseTimer1_a,
                       &fault_diagnosis_DW.IncreaseTimer1_a);
        fault_diagnosis_IncreaseTimer(U_c, ScBSW_PackMinCellVoltMv <= KaFDG_CellUnderVoltLevMv[0],
                      KaFDG_CellUnderVoltTimerMs[0], 100.0,
                      &fault_diagnosis_B.IncreaseTimer_k,
                      &fault_diagnosis_DW.IncreaseTimer_k);
        fault_diagnosis_IncreaseTimer2(U2_bw, ScBSW_PackMinCellVoltMv <=
                       KaFDG_CellUnderVoltLevMv[2], KaFDG_CellUnderVoltTimerMs[2],
                       100.0, &fault_diagnosis_B.IncreaseTimer2_j,
                       &fault_diagnosis_DW.IncreaseTimer2_j);
    }

    SbFDG_CellUnderVoltLev1Flg =
        fault_diagnosis_B.IncreaseTimer_k.RelationalOperator_k;
    SbFDG_CellUnderVoltLev2Flg =
        fault_diagnosis_B.IncreaseTimer1_a.RelationalOperator_n4;
    SbFDG_CellUnderVoltLev3Flg =
        fault_diagnosis_B.IncreaseTimer2_j.RelationalOperator_a;
    U_mq = fault_diagnosis_DW.U_DSTATE_h;
    U1_n = fault_diagnosis_DW.U1_DSTATE_gl;
    U2_b = fault_diagnosis_DW.U2_DSTATE_p;
    if (SbBSW_AfeDataGetAllFlg)
    {
        fault_diagnosis_IncreaseTimer1(U1_n, ScBSW_CellDiffVoltMv >= KaFDG_CellDiffVoltLevMv[1],
                       KaFDG_CellDiffVoltTimerMs[1], 100.0,
                       &fault_diagnosis_B.IncreaseTimer1_nf,
                       &fault_diagnosis_DW.IncreaseTimer1_nf);
        fault_diagnosis_IncreaseTimer(U_mq, ScBSW_CellDiffVoltMv >= KaFDG_CellDiffVoltLevMv[0],
                      KaFDG_CellDiffVoltTimerMs[0], 100.0,
                      &fault_diagnosis_B.IncreaseTimer_n,
                      &fault_diagnosis_DW.IncreaseTimer_n);
        fault_diagnosis_IncreaseTimer2(U2_b, ScBSW_CellDiffVoltMv >= KaFDG_CellDiffVoltLevMv[2],
                       KaFDG_CellDiffVoltTimerMs[2], 100.0,
                       &fault_diagnosis_B.IncreaseTimer2_p,
                       &fault_diagnosis_DW.IncreaseTimer2_p);
    }

    SbFDG_CellDiffVoltLev1Flg =
        fault_diagnosis_B.IncreaseTimer_n.RelationalOperator_k;
    SbFDG_CellDiffVoltLev2Flg =
        fault_diagnosis_B.IncreaseTimer1_nf.RelationalOperator_n4;
    SbFDG_CellDiffVoltLev3Flg =
        fault_diagnosis_B.IncreaseTimer2_p.RelationalOperator_a;
    U_h = fault_diagnosis_DW.U_DSTATE_e;
    U1_j = fault_diagnosis_DW.U1_DSTATE_m;
    U2_f = fault_diagnosis_DW.U2_DSTATE_h;
    if (SbBSW_AfeDataGetAllFlg)
    {
        fault_diagnosis_IncreaseTimer1(U1_j, ScBSW_PackMaxCellTempC >= KaFDG_CellOvrTempLevC[1],
                       KaFDG_CellOvrTempTimerMs[1], 100.0,
                       &fault_diagnosis_B.IncreaseTimer1_l,
                       &fault_diagnosis_DW.IncreaseTimer1_l);
        fault_diagnosis_IncreaseTimer(U_h, ScBSW_PackMaxCellTempC >= KaFDG_CellOvrTempLevC[0],
                      KaFDG_CellOvrTempTimerMs[0], 100.0,
                      &fault_diagnosis_B.IncreaseTimer_je,
                      &fault_diagnosis_DW.IncreaseTimer_je);
        fault_diagnosis_IncreaseTimer2(U2_f, ScBSW_PackMaxCellTempC >= KaFDG_CellOvrTempLevC[2],
                       KaFDG_CellOvrTempTimerMs[2], 100.0,
                       &fault_diagnosis_B.IncreaseTimer2_bd,
                       &fault_diagnosis_DW.IncreaseTimer2_bd);
    }

    SbFDG_CellOvrTempLev1Flg =
        fault_diagnosis_B.IncreaseTimer_je.RelationalOperator_k;
    SbFDG_CellOvrTempLev2Flg =
        fault_diagnosis_B.IncreaseTimer1_l.RelationalOperator_n4;
    SbFDG_CellOvrTempLev3Flg =
        fault_diagnosis_B.IncreaseTimer2_bd.RelationalOperator_a;
    U_p = fault_diagnosis_DW.U_DSTATE_p;
    U1_a = fault_diagnosis_DW.U1_DSTATE_f;
    U2_e = fault_diagnosis_DW.U2_DSTATE_b;
    if (SbBSW_AfeDataGetAllFlg)
    {
        fault_diagnosis_IncreaseTimer1(U1_a, ScBSW_CellDiffTempC >= KaFDG_CellDiffTempLevC[1],
                       KaFDG_CellDiffTempTimerMs[1], 100.0,
                       &fault_diagnosis_B.IncreaseTimer1_o2,
                       &fault_diagnosis_DW.IncreaseTimer1_o2);
        fault_diagnosis_IncreaseTimer(U_p, ScBSW_CellDiffTempC >= KaFDG_CellDiffTempLevC[0],
                      KaFDG_CellDiffTempTimerMs[0], 100.0,
                      &fault_diagnosis_B.IncreaseTimer_j,
                      &fault_diagnosis_DW.IncreaseTimer_j);
        fault_diagnosis_IncreaseTimer2(U2_e, ScBSW_CellDiffTempC >= KaFDG_CellDiffTempLevC[2],
                       KaFDG_CellDiffTempTimerMs[2], 100.0,
                       &fault_diagnosis_B.IncreaseTimer2_l,
                       &fault_diagnosis_DW.IncreaseTimer2_l);
    }

    SbFDG_CellDiffTempLev1Flg =
        fault_diagnosis_B.IncreaseTimer_j.RelationalOperator_k;
    SbFDG_CellDiffTempLev2Flg =
        fault_diagnosis_B.IncreaseTimer1_o2.RelationalOperator_n4;
    SbFDG_CellDiffTempLev3Flg =
        fault_diagnosis_B.IncreaseTimer2_l.RelationalOperator_a;
    if (SbFDG_CellOvrVoltLev2Flg)
    {
        u1 = 0U;
    }
    else
    {
        u1 = 2U;
    }

    if (SbFDG_CellOvrVoltLev3Flg)
    {
        u1_0 = 0U;
    }
    else
    {
        u1_0 = 3U;
    }

    if (SbFDG_CellUnderVoltLev2Flg)
    {
        u1_1 = 0U;
    }
    else
    {
        u1_1 = 2U;
    }

    if (SbFDG_CellUnderVoltLev3Flg)
    {
        u1_2 = 0U;
    }
    else
    {
        u1_2 = 3U;
    }

    if (SbFDG_CellDiffVoltLev2Flg)
    {
        u1_3 = 0U;
    }
    else
    {
        u1_3 = 2U;
    }

    if (SbFDG_CellDiffVoltLev3Flg)
    {
        u1_4 = 0U;
    }
    else
    {
        u1_4 = 3U;
    }

    if (SbFDG_CellOvrTempLev2Flg)
    {
        u1_5 = 0U;
    }
    else
    {
        u1_5 = 2U;
    }

    if (SbFDG_CellOvrTempLev3Flg)
    {
        u1_6 = 0U;
    }
    else
    {
        u1_6 = 3U;
    }

    if (SbFDG_CellUnderTempLev2Flg)
    {
        u1_7 = 0U;
    }
    else
    {
        u1_7 = 2U;
    }

    if (SbFDG_CellUnderTempLev3Flg)
    {
        u1_8 = 0U;
    }
    else
    {
        u1_8 = 3U;
    }

    if (SbFDG_CellDiffTempLev2Flg)
    {
        u1_9 = 0U;
    }
    else
    {
        u1_9 = 2U;
    }

    if (SbFDG_CellDiffTempLev3Flg)
    {
        u1_a = 0U;
    }
    else
    {
        u1_a = 3U;
    }

    if ((!SbFDG_CellOvrVoltLev1Flg) > u1)
    {
        u1 = 1U;
    }

    if (u1 > u1_0)
    {
        u1_0 = u1;
    }

    if ((!SbFDG_CellUnderVoltLev1Flg) > u1_1)
    {
        u1_1 = 1U;
    }

    if (u1_1 > u1_2)
    {
        u1_2 = u1_1;
    }

    if (u1_0 > u1_2)
    {
        u1_2 = u1_0;
    }

    if ((!SbFDG_CellDiffVoltLev1Flg) > u1_3)
    {
        u1_3 = 1U;
    }

    if (u1_3 > u1_4)
    {
        u1_4 = u1_3;
    }

    if (u1_2 > u1_4)
    {
        u1_4 = u1_2;
    }

    if ((!SbFDG_CellOvrTempLev1Flg) > u1_5)
    {
        u1_5 = 1U;
    }

    if (u1_5 > u1_6)
    {
        u1_6 = u1_5;
    }

    if (u1_4 > u1_6)
    {
        u1_6 = u1_4;
    }

    if ((!SbFDG_CellUnderTempLev1Flg) > u1_7)
    {
        u1_7 = 1U;
    }

    if (u1_7 > u1_8)
    {
        u1_8 = u1_7;
    }

    if (u1_6 > u1_8)
    {
        u1_8 = u1_6;
    }

    if ((!SbFDG_CellDiffTempLev1Flg) > u1_9)
    {
        u1_9 = 1U;
    }

    if (u1_9 > u1_a)
    {
        u1_a = u1_9;
    }

    if (u1_8 > u1_a)
    {
        ScFDG_PackFaltLevel = u1_8;
    }
    else
    {
        ScFDG_PackFaltLevel = u1_a;
    }

    fault_diagnosis_IncreaseTimer2(U2_e, SbFDG_CellDiffTempLev3Flg && (ScBSW_CellDiffTempC <
                    KaFDG_CellDiffTempLevRecoverC[2]),
                   KaFDG_CellDiffTempLevRecvryTimerMs[2], 100.0,
                   &fault_diagnosis_B.IncreaseTimer2_g,
                   &fault_diagnosis_DW.IncreaseTimer2_g);
    fault_diagnosis_IncreaseTimer1(U1_a, SbFDG_CellDiffTempLev2Flg && (ScBSW_CellDiffTempC <
                    KaFDG_CellDiffTempLevRecoverC[1]),
                   KaFDG_CellDiffTempLevRecvryTimerMs[1], 100.0,
                   &fault_diagnosis_B.IncreaseTimer1_n,
                   &fault_diagnosis_DW.IncreaseTimer1_n);
    fault_diagnosis_IncreaseTimer(U_p, SbFDG_CellDiffTempLev1Flg && (ScBSW_CellDiffTempC <
                   KaFDG_CellDiffTempLevRecoverC[0]),
                  KaFDG_CellDiffTempLevRecvryTimerMs[0], 100.0,
                  &fault_diagnosis_B.IncreaseTimer_g,
                  &fault_diagnosis_DW.IncreaseTimer_g);
    fault_diagnosis_IncreaseTimer2(U2_f, SbFDG_CellOvrTempLev3Flg && (ScBSW_PackMaxCellTempC <
                    KaFDG_CellOvrTempLevRecoverC[2]),
                   KaFDG_CellOvrTempLevRecvryTimerMs[2], 100.0,
                   &fault_diagnosis_B.IncreaseTimer2_c,
                   &fault_diagnosis_DW.IncreaseTimer2_c);
    fault_diagnosis_IncreaseTimer1(U1_j, SbFDG_CellOvrTempLev2Flg && (ScBSW_PackMaxCellTempC <
                    KaFDG_CellOvrTempLevRecoverC[1]),
                   KaFDG_CellOvrTempLevRecvryTimerMs[1], 100.0,
                   &fault_diagnosis_B.IncreaseTimer1_ot,
                   &fault_diagnosis_DW.IncreaseTimer1_ot);
    fault_diagnosis_IncreaseTimer(U_h, SbFDG_CellOvrTempLev1Flg && (ScBSW_PackMaxCellTempC <
                   KaFDG_CellOvrTempLevRecoverC[0]),
                  KaFDG_CellOvrTempLevRecvryTimerMs[0], 100.0,
                  &fault_diagnosis_B.IncreaseTimer_b,
                  &fault_diagnosis_DW.IncreaseTimer_b);
    fault_diagnosis_IncreaseTimer2(U2_b, SbFDG_CellDiffVoltLev3Flg && (ScBSW_CellDiffVoltMv <
                    KaFDG_CellDiffVoltLevRecoverMv[2]),
                   KaFDG_CellDiffVoltLevRecvryTimerMs[2], 100.0,
                   &fault_diagnosis_B.IncreaseTimer2_b,
                   &fault_diagnosis_DW.IncreaseTimer2_b);
    fault_diagnosis_IncreaseTimer1(U1_n, SbFDG_CellDiffVoltLev2Flg && (ScBSW_CellDiffVoltMv <
                    KaFDG_CellDiffVoltLevRecoverMv[1]),
                   KaFDG_CellDiffVoltLevRecvryTimerMs[1], 100.0,
                   &fault_diagnosis_B.IncreaseTimer1_o,
                   &fault_diagnosis_DW.IncreaseTimer1_o);
    fault_diagnosis_IncreaseTimer(U_mq, SbFDG_CellDiffVoltLev1Flg && (ScBSW_CellDiffVoltMv <
                   KaFDG_CellDiffVoltLevRecoverMv[0]),
                  KaFDG_CellDiffVoltLevRecvryTimerMs[0], 100.0,
                  &fault_diagnosis_B.IncreaseTimer_o,
                  &fault_diagnosis_DW.IncreaseTimer_o);
    fault_diagnosis_IncreaseTimer2(U2_bw, SbFDG_CellUnderVoltLev3Flg && (ScBSW_PackMinCellVoltMv
                    > KaFDG_CellUnderVoltLevRecoverMv[2]),
                   KaFDG_CellUnderVoltLevRecvryTimerMs[2], 100.0,
                   &fault_diagnosis_B.IncreaseTimer2_o,
                   &fault_diagnosis_DW.IncreaseTimer2_o);
    fault_diagnosis_IncreaseTimer1(U1_c, SbFDG_CellUnderVoltLev2Flg && (ScBSW_PackMinCellVoltMv >
                    KaFDG_CellUnderVoltLevRecoverMv[1]),
                   KaFDG_CellUnderVoltLevRecvryTimerMs[1], 100.0,
                   &fault_diagnosis_B.IncreaseTimer1_e,
                   &fault_diagnosis_DW.IncreaseTimer1_e);
    fault_diagnosis_IncreaseTimer(U_c, SbFDG_CellUnderVoltLev1Flg && (ScBSW_PackMinCellVoltMv >
                   KaFDG_CellUnderVoltLevRecoverMv[0]),
                  KaFDG_CellUnderVoltLevRecvryTimerMs[0], 100.0,
                  &fault_diagnosis_B.IncreaseTimer_h,
                  &fault_diagnosis_DW.IncreaseTimer_h);
    fault_diagnosis_IncreaseTimer2(U2_d, SbFDG_CellOvrVoltLev3Flg && (ScBSW_PackMaxCellVoltMv <
                    KaFDG_CellOvrVoltLevRecoverMv[2]),
                   KaFDG_CellOvrVoltLevRecvryTimerMs[2], 100.0,
                   &fault_diagnosis_B.IncreaseTimer2_k,
                   &fault_diagnosis_DW.IncreaseTimer2_k);
    fault_diagnosis_IncreaseTimer1(U1_gg, SbFDG_CellOvrVoltLev2Flg && (ScBSW_PackMaxCellVoltMv <
                    KaFDG_CellOvrVoltLevRecoverMv[1]),
                   KaFDG_CellOvrVoltLevRecvryTimerMs[1], 100.0,
                   &fault_diagnosis_B.IncreaseTimer1_p,
                   &fault_diagnosis_DW.IncreaseTimer1_p);
    fault_diagnosis_IncreaseTimer(U, SbFDG_CellOvrVoltLev1Flg && (ScBSW_PackMaxCellVoltMv <
                   KaFDG_CellOvrVoltLevRecoverMv[0]),
                  KaFDG_CellOvrVoltLevRecvryTimerMs[0], 100.0,
                  &fault_diagnosis_B.IncreaseTimer_fx,
                  &fault_diagnosis_DW.IncreaseTimer_fx);
    fault_diagnosis_IncreaseTimer2(U2, SbFDG_CellUnderTempLev3Flg && (ScBSW_PackMinCellTempC >
                    KaFDG_CellUnderTempLevRecoverC[2]),
                   KaFDG_CellUnderTempLevRecvryTimerMs[2], 100.0,
                   &fault_diagnosis_B.IncreaseTimer2_h,
                   &fault_diagnosis_DW.IncreaseTimer2_h);
    fault_diagnosis_IncreaseTimer1(U1, SbFDG_CellUnderTempLev2Flg && (ScBSW_PackMinCellTempC >
                    KaFDG_CellUnderTempLevRecoverC[1]),
                   KaFDG_CellUnderTempLevRecvryTimerMs[1], 100.0,
                   &fault_diagnosis_B.IncreaseTimer1_g,
                   &fault_diagnosis_DW.IncreaseTimer1_g);
    U1 = (USART1_RxGetCounter == fault_diagnosis_DW.UnitDelay_DSTATE);
    fault_diagnosis_IncreaseTimer_f(!U1, U1, KaFDG_DevDaisyCommTimeoutMs, 100.0,
                    &fault_diagnosis_B.IncreaseTimer_f4,
                    &fault_diagnosis_DW.IncreaseTimer_f4);
    SbFDG_DevDaisyCommFlt =
        fault_diagnosis_B.IncreaseTimer_f4.RelationalOperator_p;
    fault_diagnosis_DW.U_DSTATE =
        fault_diagnosis_B.IncreaseTimer_fy.RelationalOperator_k;
    fault_diagnosis_DW.U1_DSTATE =
        fault_diagnosis_B.IncreaseTimer1_g.RelationalOperator_n4;
    fault_diagnosis_DW.U2_DSTATE =
        fault_diagnosis_B.IncreaseTimer2_h.RelationalOperator_a;
    fault_diagnosis_DW.U_DSTATE_i =
        fault_diagnosis_B.IncreaseTimer_fx.RelationalOperator_k;
    fault_diagnosis_DW.U1_DSTATE_l =
        fault_diagnosis_B.IncreaseTimer1_p.RelationalOperator_n4;
    fault_diagnosis_DW.U2_DSTATE_n =
        fault_diagnosis_B.IncreaseTimer2_k.RelationalOperator_a;
    fault_diagnosis_DW.U_DSTATE_k =
        fault_diagnosis_B.IncreaseTimer_h.RelationalOperator_k;
    fault_diagnosis_DW.U1_DSTATE_g =
        fault_diagnosis_B.IncreaseTimer1_e.RelationalOperator_n4;
    fault_diagnosis_DW.U2_DSTATE_d =
        fault_diagnosis_B.IncreaseTimer2_o.RelationalOperator_a;
    fault_diagnosis_DW.U_DSTATE_h =
        fault_diagnosis_B.IncreaseTimer_o.RelationalOperator_k;
    fault_diagnosis_DW.U1_DSTATE_gl =
        fault_diagnosis_B.IncreaseTimer1_o.RelationalOperator_n4;
    fault_diagnosis_DW.U2_DSTATE_p =
        fault_diagnosis_B.IncreaseTimer2_b.RelationalOperator_a;
    fault_diagnosis_DW.U_DSTATE_e =
        fault_diagnosis_B.IncreaseTimer_b.RelationalOperator_k;
    fault_diagnosis_DW.U1_DSTATE_m =
        fault_diagnosis_B.IncreaseTimer1_ot.RelationalOperator_n4;
    fault_diagnosis_DW.U2_DSTATE_h =
        fault_diagnosis_B.IncreaseTimer2_c.RelationalOperator_a;
    fault_diagnosis_DW.U_DSTATE_p =
        fault_diagnosis_B.IncreaseTimer_g.RelationalOperator_k;
    fault_diagnosis_DW.U1_DSTATE_f =
        fault_diagnosis_B.IncreaseTimer1_n.RelationalOperator_n4;
    fault_diagnosis_DW.U2_DSTATE_b =
        fault_diagnosis_B.IncreaseTimer2_g.RelationalOperator_a;
    fault_diagnosis_DW.UnitDelay_DSTATE = USART1_RxGetCounter;
}

/* Model initialize function */
void fault_diagnosis_initialize(void)
{
    /* (no initialization code required) */
}

/*
 * File trailer for generated code.
 *
 * [EOF]
 */
